package com.lwx.sz3e;

import java.util.HashMap;
import java.util.Map;

import javax.mail.MessagingException;

public class YuYue {
  public static void main(String[] args) throws MessagingException {
    while(true){
      try {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("sldw", "440305000000");
        paramMap.put("beginDate", "2015-01-08");
        paramMap.put("type", "new");
        paramMap.put("days", "7");
        
        String result = HTTPClientUtil.sendPostRequest("http://yysl.sz3e.com/wsyysq/gzRegionTbAction/getSlsjBySldw.do", paramMap);
        System.err.println(result);
        
        String leftNum09 = ExtractUtil.getFirstContent(result, "\"09:00-10:00\",\"2015-01-09\",\"(\\d+)\",\"09:00\",\"10:00\"", 1);
        String leftNum12 = ExtractUtil.getFirstContent(result, "\"09:00-10:00\",\"2015-01-12\",\"(\\d+)\",\"09:00\",\"10:00\"", 1);
        String leftNum13 = ExtractUtil.getFirstContent(result, "\"09:00-10:00\",\"2015-01-13\",\"(\\d+)\",\"09:00\",\"10:00\"", 1);
        if(!"0".equals(leftNum09) || !"0".equals(leftNum12)|| !"0".equals(leftNum13)){
          System.out.println("有号了");
          SendMail.sendMessage("smtp.163.com", "lwx522@163.com",
            "LWX9673164775", "wenxin.liang@tcl.com", "有号了",
            "有号了",
            "text/html;charset=gb2312");
        }
      } catch (Exception e) {
        // TODO: handle exception
      }
      
    }
  }
}
